/**
 * Created on May 13, 2007
 */
package jvs.vfs.io;

import java.io.IOException;
import java.io.InputStream;

/**
 * Unix /dev/null
 * 
 * @author qiangli
 *
 */
public class NullInputStream extends InputStream {

	/**
	 * 
	 */
	public NullInputStream() {
		
	}

	/* (non-Javadoc)
	 * @see java.io.InputStream#read()
	 */
	public int read() throws IOException {
		return -1;
	}

	public int available() throws IOException {
		return 0;
	}

	public void close() throws IOException {
	}

	public synchronized void mark(int readlimit) {
	}

	public boolean markSupported() {
		return false;
	}

	public int read(byte[] b, int off, int len) throws IOException {
		if (b == null) throw new NullPointerException();
		if (off < 0 || len < 0 || off+len > b.length) throw new IndexOutOfBoundsException();
		if (len == 0) return 0;
		return -1;
	}

	public int read(byte[] b) throws IOException {
		if (b == null) throw new NullPointerException();
		if (b.length == 0) return 0;
		return -1;
	}

	public synchronized void reset() throws IOException {
		throw new IOException();
	}

	public long skip(long n) throws IOException {
		return 0;
	}
	
}
